package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TVideoComment;
import com.ruoyi.system.service.ITVideoCommentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 视频评论Controller
 * 
 * @author ruoyi
 * @date 2025-09-24
 */
@RestController
@RequestMapping("/system/videocomment")
public class TVideoCommentController extends BaseController
{
    @Autowired
    private ITVideoCommentService tVideoCommentService;

    /**
     * 查询视频评论列表
     */
    @PreAuthorize("@ss.hasPermi('system:comment:list')")
    @GetMapping("/list")
    public TableDataInfo list(TVideoComment tVideoComment)
    {
        startPage();
        List<TVideoComment> list = tVideoCommentService.selectTVideoCommentList(tVideoComment);
        return getDataTable(list);
    }

    /**
     * 导出视频评论列表
     */
    @PreAuthorize("@ss.hasPermi('system:comment:export')")
    @Log(title = "视频评论", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TVideoComment tVideoComment)
    {
        List<TVideoComment> list = tVideoCommentService.selectTVideoCommentList(tVideoComment);
        ExcelUtil<TVideoComment> util = new ExcelUtil<TVideoComment>(TVideoComment.class);
        util.exportExcel(response, list, "视频评论数据");
    }

    /**
     * 获取视频评论详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:comment:query')")
    @GetMapping(value = "/{videoCommentId}")
    public AjaxResult getInfo(@PathVariable("videoCommentId") Long videoCommentId)
    {
        return success(tVideoCommentService.selectTVideoCommentByVideoCommentId(videoCommentId));
    }

    /**
     * 新增视频评论
     */
    @PreAuthorize("@ss.hasPermi('system:comment:add')")
    @Log(title = "视频评论", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TVideoComment tVideoComment)
    {
        return toAjax(tVideoCommentService.insertTVideoComment(tVideoComment));
    }

    /**
     * 修改视频评论
     */
    @PreAuthorize("@ss.hasPermi('system:comment:edit')")
    @Log(title = "视频评论", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TVideoComment tVideoComment)
    {
        return toAjax(tVideoCommentService.updateTVideoComment(tVideoComment));
    }

    /**
     * 删除视频评论
     */
    @PreAuthorize("@ss.hasPermi('system:comment:remove')")
    @Log(title = "视频评论", businessType = BusinessType.DELETE)
	@DeleteMapping("/{videoCommentIds}")
    public AjaxResult remove(@PathVariable Long[] videoCommentIds)
    {
        return toAjax(tVideoCommentService.deleteTVideoCommentByVideoCommentIds(videoCommentIds));
    }
}
